home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / misc / iv26_w30 / sources / dialog.c < prev    next >
C/C++ Source or Header  |  1980-01-03  |  2KB  |  84 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Dialog class implementation.
  25.  */
  26.  
  27. #include <InterViews/button.h>
  28. #include <InterViews/dialog.h>
  29. #include <InterViews/event.h>
  30. #include <InterViews/world.h>
  31.  
  32. Dialog::Dialog (ButtonState* b, Interactor* i, Alignment a) {
  33.     Init(b, i, a);
  34. }
  35.  
  36. Dialog::Dialog (const char* name, ButtonState* b, Interactor* i, Alignment a) {
  37.     SetInstance(name);
  38.     Init(b, i, a);
  39. }
  40.  
  41. void Dialog::Init (ButtonState* b, Interactor* i, Alignment a) {
  42.     SetClassName("Dialog");
  43.     state = b;
  44.     align = a;
  45.     Insert(i);
  46. }
  47.  
  48. boolean Dialog::Popup (Event& e, boolean placed) {
  49.     World* w;
  50.     Coord wx, wy;
  51.     boolean accept;
  52.  
  53.     e.GetAbsolute(w, wx, wy);
  54.     if (placed) {
  55.     w->InsertTransient(this, e.target, wx, wy, align);
  56.     } else {
  57.     w->InsertTransient(this, e.target);
  58.     }
  59.     accept = Accept();
  60.     w->Remove(this);
  61.     return accept;
  62. }
  63.  
  64. boolean Dialog::Accept () {
  65.     Event e;
  66.     int v;
  67.  
  68.     state->SetValue(0);
  69.     v = 0;
  70.     do {
  71.     Read(e);
  72.     e.target->Handle(e);
  73.     state->GetValue(v);
  74.     } while (v == 0 && e.target != nil);
  75.     return v == 1 || e.target == nil;
  76. }
  77.  
  78. int Dialog::Status () {
  79.     int v;
  80.  
  81.     state->GetValue(v);
  82.     return v;
  83. }
  84.